package com.xgp.labblog.controller;

import com.xgp.labblog.model.Writes;
import com.xgp.labblog.service.SpeakService;
import com.xgp.labblog.service.WriteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Controller
public class commentController {

    @Autowired
    WriteService writeService;

    @Autowired
    SpeakService speakService;

    @GetMapping("/comment/{id}")
    public String comment(@PathVariable(name = "id") Integer id, Model model) {
        try {
            //1,根据文章id查找文章
            Writes write = writeService.FindWriteById(id);

            model.addAttribute("writeDetails",write);

            return "html/comment";
        }catch (Exception e) {
            return "error/4xx";
        }


    }
}
